import { createBrowserRouter } from 'react-router-dom'
import App from '../App'
export const router = createBrowserRouter([
    {
        path: '/',
        element: <App></App>,

        children: [
            {
                path: '/home',

                async lazy() {
                    const { default: Home } = await import('../pages/home/Index')
                    return {
                        element: <Home></Home>,

                    }
                }
            },
            {
                path: '/order',

                async lazy() {
                    const { default: Order } = await import('../pages/order/Index')
                    return {
                        element: <Order></Order>,

                    }
                }
            },
            {
                path: '/my',

                async lazy() {
                    const { default: My } = await import('../pages/my/Index')
                    return {
                        element: <My></My>,

                    }
                },
                children: [
                    {
                        path: 'mm',
                        async lazy() {
                            const { default: Mm } = await import('../pages/my/mm/Index')
                            return {
                                element: <Mm></Mm>,

                            }
                        },
                    },
                    {
                        path: 'yy',
                        async lazy() {
                            const { default: Yy } = await import('../pages/my/yy/Index')
                            return {
                                element: <Yy></Yy>,

                            }
                        },
                    }
                ]
            }
        ]
    },
    {
        path: '*',

        async lazy() {
            const { default: Error } = await import('../pages/404/Index')
            return {
                element: <Error></Error>,
            }
        }
    }
])
export default router
